<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="../../css/oksub.css">
	<script type="text/javascript" src="../../lib/loading/okLoading.js"></script>
	<style type="text/css">
	
	</style>
</head>
<body>
<div class="ok-body">
	<!--form表单-->
	<form class="layui-form layui-form-pane ok-form">
		 <div class="layui-form-item">
			<label class="layui-form-label">员工号/账号</label>
			<div class="layui-input-inline">
				<input type="text" id="Account" name="Account" autocomplete="off" class="layui-input"	 lay-verify="required">
			</div>			
			<label class="layui-form-label">姓名</label>
			<div class="layui-input-inline">
				<input type="text" id="RealName" name="RealName" autocomplete="off" class="layui-input"	 lay-verify="required">
			</div>	
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">性别</label>
			<div class="layui-input-inline">	
				<select  id="Gender" name = "Gender"> 
				<option value='1'>男</option>
						<option value='2'>女</option>					
				</select>
			</div>	
		
			<label class="layui-form-label">手机</label>
			<div class="layui-input-inline">	
				<input type="text" id="Mobile" name="Mobile" autocomplete="off" class="layui-input"	 lay-verify="required">
			</div>	
		</div>	
		<div class="layui-form-item">
			<label class="layui-form-label">部门</label>
			<div class="layui-input-inline">	
				<select  id="DepartmentId" name = "DepartmentId"> 					
				</select>
			</div>	
		
			<label class="layui-form-label">角色</label>
			<div class="layui-input-inline">	
				<select  id="RoleId" name = "RoleId"> 					
				</select>
			</div>	
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">职位</label>
			<div class="layui-input-inline">	
				<select  id="DutyId" name = "DutyId"> 					
				</select>
			</div>		
			<label class="layui-form-label">岗位</label>
			<div class="layui-input-inline">	
				<select  id="PostId" name = "PostId"> 					
				</select>
			</div>	
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">排序</label>
			<div class="layui-input-inline">
				<input type="text" id="SortCode" name="SortCode"  autocomplete="off" class="layui-input"	 lay-verify="required">
			</div>	
			<label class="layui-form-label">邮箱</label>
			<div class="layui-input-inline">
				<input type="text" id="Email" name="Email"  autocomplete="off" class="layui-input"	 lay-verify="required">
			</div>	
		</div>
		
	</form>
	
</div>
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script src="../../js/okform.js"></script>
<script>
     
    var ID = request("ID"); 
    var ManagerId = "";
    
    function AcceptClick() {
    	layui.use([ "okUtils"], function () {
    		let okUtils = layui.okUtils;
    		let $ = layui.jquery;
    		var saveCondition = {};
    		saveCondition['UserId'] = ID;
    		saveCondition['Account'] = $("#Account").val();
    		saveCondition['RealName'] =encodeURI($("#RealName").val().trim());
    		
    		saveCondition['Gender'] = $("#Gender").val();
    		saveCondition['Mobile'] = $("#Mobile").val();
    		saveCondition['DepartmentId'] = $("#DepartmentId").val();
    		saveCondition['RoleId'] = $("#RoleId").val();
    		saveCondition['DutyId'] = $("#DutyId").val();
    		saveCondition['PostId'] = $("#PostId").val();
    		saveCondition['Email'] = $("#Email").val();    		
    		saveCondition['SortCode'] = $("#SortCode").val();
    	
    		
    		var searchcondition = JSON.stringify(saveCondition)
    		
    		okUtils.ajax("UserServlet?method=save", "get", {searchcondition: searchcondition}, true).done(function (response) {
				   console.log(response);
				  
				}).fail(function (error) {
					console.log(error)
				});
    	})
    
    }
    
    
	layui.use(["element", "form","jquery", "laydate", "okLayer", "okUtils", "okMock"], function () {
		let form = layui.form;
		let laydate = layui.laydate;
		let okLayer = layui.okLayer;
		let okUtils = layui.okUtils;
		let table = layui.table;
		let okMock = layui.okMock;
		let $ = layui.jquery;
		
		okLoading.close();	
		okUtils.ajax("DepartmentServlet?method=getDepartmentSelect", "get", null, true).done(function (response) {
			var data = response.data;
			 var txtconent = "<option value='0'>请选择</option>";
			  for(var i = 0; i < data.length; i ++){
				  txtconent = txtconent + "<option value='"+data[i].DepartmentId+"'>"+data[i].FullName+"</option>"
			  }
			  $("#DepartmentId").html(txtconent);
			 // form.render();	
			 
			  okUtils.ajax("RoleServlet?method=geRoleSelect", "get", null, true).done(function (response) {
					var data = response.data;
					 var txtRconent = "<option value='0'>请选择</option>";
					 var txtDconent = "<option value='0'>请选择</option>";
					 var txtPconent = "<option value='0'>请选择</option>";
					  for(var i = 0; i < data.length; i ++){
						  if(data[i].Type == 1 ){ 
							  txtRconent = txtRconent + "<option value='"+data[i].RoleId+"'>"+data[i].FullName+"</option>"
						  }
						  else if(data[i].Type == 2 ){ 
							  txtDconent = txtDconent + "<option value='"+data[i].RoleId+"'>"+data[i].FullName+"</option>"
						  }
						  else if(data[i].Type == 3 ){ 
							  txtPconent = txtPconent + "<option value='"+data[i].RoleId+"'>"+data[i].FullName+"</option>"
						  }
					 }
					  $("#RoleId").html(txtRconent);
					  $("#DutyId").html(txtDconent);
					  $("#PostId").html(txtPconent);
					  form.render();
					  if(ID){		 
							 okUtils.ajax("UserServlet?method=getOneData", "get", {ID: ID}, true).done(function (response) {
								   var data =response.data;
								   ID = data.UserId;
								   $("#Account").val(data.Account);
								   $("#RealName").val(data.RealName);
								   
								   $("#Gender").val(data.Gender);
								   $("#Mobile").val(data.Mobile);
								   $("#DepartmentId").val(data.DepartmentId);
								   $("#RoleId").val(data.RoleId);
								   $("#DutyId").val(data.DutyId);
								   $("#PostId").val(data.PostId);
								   $("#SortCode").val(data.SortCode);						  
								   $("#Email").val(data.Email);
								   form.render();
								}).fail(function (error) {
									console.log(error)
								});
						 }
					
				 }).fail(function (error) {
						console.log(error)
				 });

			
		 }).fail(function (error) {
				console.log(error)
		 });
		
		
	});
</script>
<!-- 行工具栏模板 -->
<script type="text/html" id="operationTpl">
	<a href="javascript:" title="编辑" lay-event="add"><i class="layui-icon">&#xe624;</i></a>
	<a href="javascript:" title="删除" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
</script>
</body>
</html>
